// 初始化开关状态
document.addEventListener('DOMContentLoaded', () => {
  const toggleSwitch = document.getElementById('hotkey-toggle');
  
  // 获取当前状态
  chrome.storage.sync.get(['hotkeyEnabled'], (result) => {
    toggleSwitch.checked = result.hotkeyEnabled !== false;
  });
  
  // 监听开关变化
  toggleSwitch.addEventListener('change', (e) => {
    const enabled = e.target.checked;
    
    // 更新存储状态
    chrome.storage.sync.set({ hotkeyEnabled: enabled }, () => {
      // 通知所有标签页更新状态
      chrome.runtime.sendMessage({ 
        action: 'setEnabledStatus', 
        enabled: enabled 
      });
    });
  });
});
